ostbuild: Ensure user chroot mounts are not shared
authorColin Walters <walters@verbum.org>
Tue, 6 Dec 2011 17:18:17 +0000 (12:18 -0500)
committerColin Walters <walters@verbum.org>
Tue, 6 Dec 2011 17:18:17 +0000 (12:18 -0500)
It's possible that the root filesystem mount is global; we need
to undo that in order to be sure that our "private" bind mounts
really are private.

src/ostbuild/ostbuild-user-chroot.c

index 80267485f74cbbd5b948bbfe9f2e4154b9ad8cc2..c0ed1a2bd4c7b803ee002578ea3035f05627d3b1 100644 (file)
@@ -98,6 +98,9 @@ main (int      argc,
   if (unshare (CLONE_NEWNS) < 0)
     fatal_errno ("unshare (CLONE_NEWNS)");
 
+  if (mount ("/", "/", "none", MS_PRIVATE, NULL) < 0)
+    fatal_errno ("mount(/, MS_PRIVATE)");
+
   initialize_chroot (chroot_dir);
 
   if (chroot (chroot_dir) < 0)